package com.ndp.fb.rdb.api;

import com.ndp.fb.model.business.vo.cache.result.AudienceForPublish;
import com.ndp.fb.rdb.model.customaudience.CustomAudienceItem;
import com.ndp.fb.rdb.model.customaudience.CustomAudienceItemWithName;

import java.util.List;

/**
 * Created by Evan on 12/9/2015.
 */
public interface CustomAudienceRdbService {

    /**
     * 根据自定义受众id查询自定义受众
     * @param id
     * @return
     */
    CustomAudienceItem findById(Long id);

    //根据模板id找到所有自定义受众
    List<CustomAudienceItem> findByTmplId(List<Long> tmplId);
    List<CustomAudienceItem> findByTemplateId(Long tmplId);
    List<CustomAudienceItem> findAllByTmplId(List<Long> tmplId);

    //查找账号下在我们系统可用的自定义受众
    List<AudienceForPublish> findPassedByAccountId(List<Long> accountIds, Long appId);


    /**
     * 按照 templateId 和accountId 进行查询
     */
    List<CustomAudienceItem> findByTemplateIdAndAccountId(Long templateId,Long accountId);

    //查找账号下的所有自定义受众
    List<Long> findByAccountId(Long accountId);

    //更新为删除
    void updateIsDelete(List<Long> customAudienceIds,String reason);

    //由受众id查找
    CustomAudienceItemWithName findByCustomAudienceId(Long fbCustomAudienceId);

    //由受众id更新
    void updateByCustomAudienceId(CustomAudienceItem item);

    /**
     * 批量保存自定义受众
     * @param customAudienceItemList
     */
    List<Long> batchSaveCustomAudience(List<CustomAudienceItem> customAudienceItemList);

    /**
     * 保存自定义受众
     * @param customAudienceItem
     * @return
     */
    Long saveCustomAudience(CustomAudienceItem customAudienceItem);

    void updateRequestQueueStatus(Long customAudienceDbId, int i);

    void updateRequestQueueStatusById(Long aLong, int i);

    void updateVersionAndRequestQueueStatus(Long customAudienceDbId, String version, int status);
    void updateVersionAndRequestQueueStatusAndFBStatus(Long customAudienceDbId, String version, int status);
    void updateDeliveryStatusDescriptionAndStatus(Long customAudienceDbId,int status,String description);


    //更新fb受众id
    void updateFbCustomAudienceId(Long id, Long fbCustomAudienceId);
    void updateFbCustomAudienceIdAndStatus(Long id, Long fbCustomAudienceId,int status);

    void updateRequestQueueStatus(String customAudienceDbId, String version, int status);

    /**
     * 更新模板id 删除自定义受众  更新is_delete =1
     */
    void delByTmplIds(List<Long> tmplIds,String delReason);

    /**
     * 自定义受众模板ID
     * @param customAudienceTemplateId
     * @return 自定义受众项列表
     */
    List<CustomAudienceItem> getCustomAudienceItemListByTemplateId(String userId,Long customAudienceTemplateId);


    void deleteByFbConnObjIds(List<Long> fbConnObjIds,String delReason);

}
